package com.smedi.ismedi.inmail.core.application.service.impl;

import com.smedi.ismedi.inmail.core.application.convert.AppConverter;
import com.smedi.ismedi.inmail.core.application.service.UserActionApplicationService;
import com.smedi.ismedi.inmail.core.domain.aggregatemodel.UserActionLog;
import com.smedi.ismedi.inmail.core.domain.repository.UserActionLogRepository;
import com.smedi.ismedi.inmail.core.port.adapter.persistence.model.UserActionLogEntity;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @className: UserActionApplicationServiceImpl
 * @Description: TODO
 * @version: v1.0.0
 * @author: wzx
 * @date: 2022/10/8 13:27
 */

@Service
@RequiredArgsConstructor
@Transactional
@Slf4j
public class UserActionApplicationServiceImpl implements UserActionApplicationService {

    private final UserActionLogRepository userActionLogRepository;

    private final AppConverter appConverter;

    @Override
    public Boolean saveUserActionLog(UserActionLog userActionLog) {
        UserActionLogEntity entity = appConverter.userActionLogToUserActionLogEntity(userActionLog);
        int id = userActionLogRepository.save(entity);
        return id > 0;
    }

}